<html>
<!-- Mirrored from infohost.nmt.edu/tcc/help/pubs/tkinter/web/entry-scrolling.html by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 06 Nov 2017 11:41:47 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=UTF-8" /><!-- /Added by HTTrack -->
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>10.1. Scrolling an Entry widget</title><link rel="stylesheet" href="css/docbook.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.70.1"><link rel="start" href="index.html" title="Tkinter 8.5 reference: a GUI for Python"><link rel="up" href="entry.html" title="10. The Entry widget"><link rel="prev" href="entry.html" title="10. The Entry widget"><link rel="next" href="entry-validation.html" title="10.2. Adding validation to an Entry
      widget"></head><body><div class="topnavbar"><a href="entry-validation.html">Next</a> / <a href="entry.html">Previous</a> / <a href="index.html">Contents</a></div><div class="navheader"><table width="100%" summary="Navigation header"><tr valign="top"><td align="left" valign="top"><h1><span class="application">Tkinter</span> 8.5 reference: a GUI for Python</h1></td><td><img alt="organizational logo" src="img/logo.png"></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="entry-scrolling"></a>10.1. Scrolling an <code class="code">Entry</code> widget</h3></div></div></div><p>
        Making an <code class="code">Entry</code> widget scrollable requires
        a little extra code on your part to adapt the <code class="code">Scrollbar</code> widget's callback to the methods
        available on the <code class="code">Entry</code> widget.  Here are
        some code fragments illustrating the setup.  First, the
        creation and linking of the <code class="code">Entry</code> and
        <code class="code">Scrollbar</code> widgets:
      </p><pre class="programlisting">    self.entry = tk.Entry(self, width=10)
    self.entry.grid(row=0, sticky=tk.E+tk.W)

    self.entryScroll = tk.Scrollbar(self, orient=tk.HORIZONTAL,
        command=self.__scrollHandler)
    self.entryScroll.grid(row=1, sticky=tk.E+tk.W)
    self.entry['xscrollcommand'] = self.entryScroll.set
</pre><p>
        Here's the adapter function referred to above:
      </p><pre class="programlisting">    def __scrollHandler(self, *L):
        op, howMany = L[0], L[1]

        if op == 'scroll':
            units = L[2]
            self.entry.xview_scroll(howMany, units)
        elif op == 'moveto':
            self.entry.xview_moveto(howMany)
</pre></div><hr><div class="navfooter"><div class="botlinks"><div class="bot-next"><b>Next: </b><a href="entry-validation.html">10.2. Adding validation to an <code class="code">Entry</code>
      widget</a></div><div class="bot-contents"><b>Contents: </b><a href="index.html"><span class="application">Tkinter</span> 8.5 reference: a GUI for Python</a></div><div class="bot-prev"><b>Previous: </b><a href="entry.html">10. The <code class="code">Entry</code> widget</a></div><div><b>Home: </b><a href="http://www.nmt.edu/">About New Mexico Tech</a></div></div><hr><div class="colophon"><address><div class="colophon-author">John W. Shipman</div><div class="colophon-mailto">Comments welcome: <a href="mailto:tcc-doc@nmt.edu">tcc-doc@nmt.edu</a></div></address><div class="colophon-date">Last updated: 2013-12-31 17:59</div><div class="colophon-url">URL: <span class="colophon-uri">http://www.nmt.edu/tcc/help/pubs/tkinter/web/entry-scrolling.html</span></div></div></div></body>
<!-- Mirrored from infohost.nmt.edu/tcc/help/pubs/tkinter/web/entry-scrolling.html by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 06 Nov 2017 11:41:47 GMT -->
</html>
